<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%><%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<s:include value="/WEB-INF/includes/css.jsp" />
	<s:include value="/WEB-INF/includes/javascript.jsp" />
	<script type="text/javascript" src="<s:url value="/js/admin/edit-role.js" />"></script>
	<title><s:text name="title" /></title>
</head>
<body>
	<div id="container">
		<s:include value="/WEB-INF/includes/header.jsp" />
		<div id="content">
			<s:include value="/WEB-INF/includes/admin/content-nav.jsp" />
			<div id="content-body">
				<h2><s:text name="roles" /></h2>
				<s:if test="actionErrors.size() > 0">
					<div class="error rounded">
						<s:iterator value="actionErrors"><s:property /><br /></s:iterator>
					</div>
				</s:if>
				<div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
					<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
						<li class="ui-state-default ui-corner-top ui-state-active"><a href="#tab-edit"><s:text name="edit-role.form.label" /></a></li>
						<li class="ui-state-default ui-corner-top"><a href="#tab-permissions"><s:text name="edit-permissions.form.label" /></a></li>
						<li class="ui-state-default ui-corner-top"><a href="#tab-permissions2"><s:text name="edit-permissions.form.label" /></a></li>
					</ul>
					<div id="tab-edit" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
						<s:form id="update_role" action="update-role" validate="true" cssClass="fixed">
			            	<s:hidden key="id" />
			            	<s:textfield key="name" required="true" cssClass="txt" />
			            	<s:textarea key="description" required="true" cssClass="txt" />
			            	
	            			<fieldset>
	            				<legend><s:text name="role.permissions" /></legend>
	            				<s:checkbox key="permissions.canAddCategory" cssClass="checkbox" />
	            				<s:checkbox key="permissions.canEditCategory" cssClass="checkbox" />
	            				<s:checkbox key="permissions.canAddRole" cssClass="checkbox" />
	            				<s:checkbox key="permissions.canEditRole" cssClass="checkbox" />
	            				<s:checkbox key="permissions.canAdminAccess" cssClass="checkbox" />
	            			</fieldset>
	            			<s:if test="!categoryMap.isEmpty()">
	            			
	            				<table class="permissions">
	            					<thead><tr><th colspan="2"><s:text name="categories" /></th></tr></thead>
	            					<tbody>
	            						<s:iterator value="categoryMap"><tr>
	            							<td><s:property value="key.name" /></td>
	            							<td><a href="#">Assign Permissions</a></td>
	            						</tr></s:iterator>
	            					</tbody>
	            				</table>
	            			
	            			<fieldset>
	            				<legend><s:text name="category.permissionss" /></legend>
	            				<table class="permissions">
	            					<thead>
					            		<tr>
					            			<th><s:text name="categories" /></th>
					            			<th class="check"><s:text name="category-permissions.canRead" /></th>
					            			<th class="check"><s:text name="category-permissions.canAddDiscussion" /></th>
					            			<th class="check"><s:text name="category-permissions.canAddResponse" /></th>
					            			<th class="check"><s:text name="category-permissions.canEditDiscussion" /></th>
					            			<th class="check"><s:text name="category-permissions.canEditResponse" /></th>
					            			<th class="check"><s:text name="category-permissions.canRemoveDiscussion" /></th>
					            			<th class="check"><s:text name="category-permissions.canRemoveResponse" /></th>
					            			<th class="check"><s:text name="category-permissions.canSetLock" /></th>
					            			<th class="check"><s:text name="category-permissions.canSetSticky" /></th>
					            		</tr>
				            		</thead>
				            		<tbody>
				            			<s:iterator value="categoryMap" status="i"><tr>
				            				<td><s:property value="key.name" /><input type="hidden" name="categoryAcls[<s:property value="#i.index" />].category.id" value="<s:property value="key.id" />" /></td>
				            				<td class="check"><input name="categoryAcls[<s:property value="#i.index" />].permissions.canRead" type="checkbox" value="true" <s:if test="value.canRead">checked="checked"</s:if>/></td>
				            				<td class="check"><input name="categoryAcls[<s:property value="#i.index" />].permissions.canAddDiscussion" type="checkbox" value="true" <s:if test="value.canAddDiscussion">checked="checked"</s:if>/></td>
				            				<td class="check"><input name="categoryAcls[<s:property value="#i.index" />].permissions.canAddResponse" type="checkbox" value="true" <s:if test="value.canAddResponse">checked="checked"</s:if>/></td>
				            				<td class="check"><input name="categoryAcls[<s:property value="#i.index" />].permissions.canEditDiscussion" type="checkbox" value="true" <s:if test="value.canEditDiscussion">checked="checked"</s:if>/></td>
				            				<td class="check"><input name="categoryAcls[<s:property value="#i.index" />].permissions.canEditResponse" type="checkbox" value="true" <s:if test="value.canEditResponse">checked="checked"</s:if>/></td>
				            				<td class="check"><input name="categoryAcls[<s:property value="#i.index" />].permissions.canRemoveDiscussion" type="checkbox" value="true" <s:if test="value.canRemoveDiscussion">checked="checked"</s:if>/></td>
				            				<td class="check"><input name="categoryAcls[<s:property value="#i.index" />].permissions.canRemoveResponse" type="checkbox" value="true" <s:if test="value.canRemoveResponse">checked="checked"</s:if>/></td>
				            				<td class="check"><input name="categoryAcls[<s:property value="#i.index" />].permissions.canSetLock" type="checkbox" value="true" <s:if test="value.canSetLock">checked="checked"</s:if>/></td>
				            				<td class="check"><input name="categoryAcls[<s:property value="#i.index" />].permissions.canSetSticky" type="checkbox" value="true" <s:if test="value.canSetSticky">checked="checked"</s:if>/></td>
				            			</tr></s:iterator>
				            		</tbody>
	            				</table>
	            			</fieldset>
	            			</s:if>
			            	<div class="field"><s:submit key="edit-role.form.save" /></div>
			            </s:form>
		            </div>
		            <div id="tab-permissions" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">
		            	<div class="form-body">
		            		<p><s:text name="edit-role.permissions.content" /></p>
		            		<div class="field" id="category_acls_categoriesGroup">
		            			<label for="category_acls" id="category_aclsLabel"><s:text name="assigned.categories" /></label>
								<select name="category_acls" size="5" id="category_acls" class="txt">
								    <option value=""><s:text name="loading.message" /></option>
								</select>
								<input type="hidden" id="category_acls_json_url" value="<s:url action="json-role-category-acl" />" />
								<input type="hidden" id="remove_category_acl_url" value="<s:url action="remove-category-acl" />" />
							</div>
		            		<div class="field">
		            			<input value="Add" id="category_acls_add" type="button" />
		            			<input value="Remove" id="category_acls_remove" type="button" />
		            		</div>
		            	</div>
		            	<div id="set_permissions" title="Set Permissions">
			            	<form id="update_category_acl" action="<s:url action="update-category-acl" />" method="post">
			            		<div class="hidden">
			            			<input type="hidden" name="id" id="update_category_acl_id" value="" />
			            			<input type="hidden" name="categoryId" id="update_category_acl_categoryId" value="" />
			            			<input type="hidden" name="roleId" id="update_category_acl_roleId" value="" />
			            		</div>
				            	<table class="permissions">
				            		<thead>
					            		<tr>
					            			<th><s:text name="permissions" /></th>
					            			<th class="check"><s:text name="allow" /></th>
					            		</tr>
				            		</thead>
				            		<tbody>
					            		<tr class="odd">
					            			<td><label for="update_category_acl_canAddDiscussion"><s:text name="category-permissions.canAddDiscussion" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canAddDiscussion" id="update_category_acl_canAddDiscussion" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr>
					            			<td><label for="update_category_acl_canAddResponse"><s:text name="category-permissions.canAddResponse" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canAddResponse" id="update_category_acl_canAddResponse" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr class="odd">
					            			<td><label for="update_category_acl_canEditDiscussion"><s:text name="category-permissions.canEditDiscussion" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canEditDiscussion" id="update_category_acl_canEditDiscussion" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr>
					            			<td><label for="update_category_acl_canEditResponse"><s:text name="category-permissions.canEditResponse" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canEditResponse" id="update_category_acl_canEditResponse" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr class="odd">
					            			<td><label for="update_category_acl_canRemoveDiscussion"><s:text name="category-permissions.canRemoveDiscussion" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canRemoveDiscussion" id="update_category_acl_canRemoveDiscussion" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr>
					            			<td><label for="update_category_acl_canRemoveResponse"><s:text name="category-permissions.canRemoveResponse" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canRemoveResponse" id="update_category_acl_canRemoveResponse" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr class="odd">
					            			<td><label for="update_category_acl_canSetLock"><s:text name="category-permissions.canSetLock" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canSetLock" id="update_category_acl_canSetLock" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr>
					            			<td><label for="update_category_acl_canSetSticky"><s:text name="category-permissions.canSetSticky" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canSetSticky" id="update_category_acl_canSetSticky" type="checkbox" value="true" />
					            			</td>
					            		</tr>
				            		</tbody>
				            	</table>
			            	</form>
		            	</div>
		            	<div id="add_category" title="<s:text name="add.category" />">
			            	<s:form action="create-category-acl" cssClass="fixed">
			            		<s:select key="categories" name="categoryId" cssClass="txt" list="#{}" />
			            		<s:hidden name="roleId" value="%{id}" />
			            		<input type="hidden" id="category_json_url" value="<s:url action="json-categories" />" />
			            	</s:form>
		            	</div>
		            </div>
		            <div id="tab-permissions2" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">
		            	<p>&lt;Put info here that describes what the user should do on this tab&gt;</p>
		            	<div style="width: 100%; height: 100%; border: 1px solid black;">
		            		<div style="width: 300px; border: 1px solid red; float: left; margin: 10px;">
		            			<ul class="itemlist">
		            				<s:iterator value="categoryMap"><li><s:property value="key.name" /></li>
		            				</s:iterator>
		            			</ul>
		            		</div>
		            		<div style="width: 300px; border: 1px solid red; float: left; margin: 10px;">
		            			<table class="permissions">
				            		<thead>
					            		<tr>
					            			<th><s:text name="permissions" /></th>
					            			<th class="check"><s:text name="allow" /></th>
					            		</tr>
				            		</thead>
				            		<tbody>
					            		<tr class="odd">
					            			<td><label for="update_category_acl_canAddDiscussion"><s:text name="category-permissions.canAddDiscussion" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canAddDiscussion" id="update_category_acl_canAddDiscussion" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr>
					            			<td><label for="update_category_acl_canAddResponse"><s:text name="category-permissions.canAddResponse" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canAddResponse" id="update_category_acl_canAddResponse" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr class="odd">
					            			<td><label for="update_category_acl_canEditDiscussion"><s:text name="category-permissions.canEditDiscussion" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canEditDiscussion" id="update_category_acl_canEditDiscussion" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr>
					            			<td><label for="update_category_acl_canEditResponse"><s:text name="category-permissions.canEditResponse" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canEditResponse" id="update_category_acl_canEditResponse" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr class="odd">
					            			<td><label for="update_category_acl_canRemoveDiscussion"><s:text name="category-permissions.canRemoveDiscussion" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canRemoveDiscussion" id="update_category_acl_canRemoveDiscussion" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr>
					            			<td><label for="update_category_acl_canRemoveResponse"><s:text name="category-permissions.canRemoveResponse" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canRemoveResponse" id="update_category_acl_canRemoveResponse" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr class="odd">
					            			<td><label for="update_category_acl_canSetLock"><s:text name="category-permissions.canSetLock" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canSetLock" id="update_category_acl_canSetLock" type="checkbox" value="true" />
					            			</td>
					            		</tr>
					            		<tr>
					            			<td><label for="update_category_acl_canSetSticky"><s:text name="category-permissions.canSetSticky" /></label></td>
					            			<td class="check">
					            				<input name="permissions.canSetSticky" id="update_category_acl_canSetSticky" type="checkbox" value="true" />
					            			</td>
					            		</tr>
				            		</tbody>
				            	</table>
		            		</div>
		            		<div style="clear: both;"></div>
		            	</div>
		            </div>
	            </div>
			</div>
			<div class="clear">&nbsp;</div>
		</div>
		<s:include value="/WEB-INF/includes/footer.jsp" />
	</div>
</body>
</html>
